<?php

// THIS FILE IS NOW REDUNDANT CR 2009-05-08


/*
	This file is part of PGallery; a FrogCMS plugin.

	PGallery is free software: you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation, either version 3 of the License, or
	(at your option) any later version.

	PGallery is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with PGallery.  If not, see <http://www.gnu.org/licenses/>.
*/


/*
	This is a basic initiator class to determine which library is
	being used, create a new instance of correct class, and
	return the instance when required. Once get_object() has been 
	called, the calling script will have direct access to the processing
	functions.
	
	It is therefore assumed that public function names will be consistent 
	between libraries of GD and ImageMagick (eg. resize(), crop() must 
	do the same thing and return the same types of values.
	
	Anything specific to the library should be prefixed with the libname_.
	For example magick_setPath()
*/


// Include actual libs that do the work
require "LibGd.php";
require "LibMagick.php";


class ImageLib
{
	
	
	private $library;
	public $base;
	public $sep;
	
	
	/**
	 * Return instance of the image object that was created in constructor.
	 * Allows direct access to the right library and all of it's public functions.
	 */
	public function get_object($settings = array()){
		
		if(empty($settings)){
			$settings = Plugin::getAllSettings('pgallery');
		}
		
		switch($settings['lib']){
			case 'gd2':
				$this->library = new LibGd;
			break;
			
			case 'im':
				$this->library = new LibMagick;
				$this->library->magick_setPath(stripslashes($settings['im_path']));
			break;
		}
		
		#$this->library->setUploadPath($this->base.$this->sep.$settings['upload_path']);
		
		return $this->library;
		
	}
	
	
}